Ultimate JKA Server Restarter (Windows) (4.00)

By Cthulhu99
Date: 07-12-2010
Version: 4.00

Download

Readme

********************************************************
Server starter/restarter and crash checker for Jedi Knight: Jedi Academy.

VERSION: 4.00
Platform: Windows
Game/MOD supported: ALL
********************************************************

################################################################################

Server start/restart description:

The script will launch an auto-generated script to the background, which contains the server command line to execute.
This script will maintain a recursive mode, and if the server is closed/killed, it will reopen the process instantly.
If this script is closed/killed, the main script will start it again after the script restart time.

Nmap check method description:

This script uses the open source Nmap software (http://www.nmap.org).
Nmap requires the installation of the Windows Packet Capture Library (WinPcap).
The installer is included with the script, but you can also download it at http://www.winpcap.org.
Nmap possesses several functions and features, but this script only uses its port mapping.
The check is made by Nmap mapping the server UDP port.
If the port responded with a accepted or refused, it means the server is either running normally and responding, or the process is not running.
If the port did not answer back, it means either a firewall is blocking that port or the process is not responding.
But since the script makes local checks and that port must be opened without firewall for players to connect,
the script will assume the process is not responding and kill it.
Windows version has two Nmap check methods due to the Windows limitation in making local scans.
Check 1 is a normal Nmap scan.
This method is recommended for all those who do not have the server ip on the machine running it (routers for example).
Check 2 is a spoofed Nmap scan to trick Windows into thinking the scan comes from another IP.
This method is recommended for those with dynamic IP, LAN only server, and WAN IP stored within the machine running the process.

Ncat check method description:

Version 4.00 added a new UDP check method using Ncat.
Ncat is a tool part of the Nmap project which allows you to connect to another port on several different protocols, or allows you to open that port for others to connect.
Ncat does not requires the Windows Packet Capture Library (WinPcap).
The script however, will only use the connect-to feature of Ncat using the UDP protocol.
Ncat will attempt to connect to server and send a message.
If the server sends a reply, the server is responding normally.
If the server does not send a reply, the process is either not running or not responding.
After the ncat check is made, a check for the process status is made.
If the process does not exist, the process is not running.
If the process exists, the process is not responding and will be killed by the script.
Ncat check method is recommended for all those who can not get Nmap working, or those who needs a minimal resource usage.

################################################################################

Dynamic Rotation description:

Dynamic Rotation is a way to make several different rotations in each day of the week, to a total of seven, or each month, to a total of twelve.
By using this method the server becomes a lot more dynamic, and can help in MODs where rotation is unstable and can crash the server, making it possible
for maps at the end of the rotation to be more played in other days/months if set to a upper layer.
Rotations for each day can be set on the drotation_day.cfg file, while rotations for each month can be set on the drotation_month.cfg file.
To enable the Dynamic Rotation feature, check the script.cfg file.

Version 4.00 includes a rehash feature, making it possible to update a Dynamic Rotation without needing to wait for another day or deleting the Dynamic Rotation auto-generated file.

OBS: It's highly recommended to remove the current rotation and its vstr from the server CFG.

################################################################################

HTML server status page generator description:

Version 4.00 includes a html generator to display information such as,
process status, Dynamic Rotation status, Dynamic Rotation for the day/month, server start/restart log, and server crash log.
After generating the html file, it can either be set to a local directory or send the file to a remote directory via FTP.
To enable this feature, check the script.cfg file.

################################################################################

CGI script description:

Version 4.00 includes a CGI script (bash+html) to be used with a web server.
The script will allow you to start/stop both the script and the server, and also check the server log, start/restart log and server crash log.

OBS: This script requires that CGI is enabled within your webserver.
OBS: Windows does not have a module for running processes with a limited user account. So the script/server must be running on the same username running the web server,
and the username set in the script.cfg file, must be the same running the web server.
OBS: Running the web server on the same user you are currently logged isn't a good idea, because a window will pop up for a few seconds every time a command is executed on the CGI script.

NOTE: Setting a password on this script with the web server is highly recommended.

################################################################################

Updater description:

The updater can be set to autodownload patched scripts, and required files, or to only show the mirrors where the full
version can be download.
To enable/disable the autodownload feature, check the script.cfg file.
To run the updater, execute Updater.bat.

OBS: The updater was created in V3.00, thus any version below it is incompatible.

################################################################################

INSTALL:

1) Unpack the zip file to any folder.
2) Install WinPCAP if you haven't already (winpcap-nmap-4.11.exe). Not required for Ncat check method.
3) Check script.cfg and configure it. (All lines are described for what you need to set.)
3a) Check drotation_day.cfg or drotation_month.cfg and configure it if you have Dynamic Rotation enabled.
4) Run JAScript.exe.
4a) Check cgi-bin/jkascript.cgi, configure it, and put it in your cgi web folder if you plan on using the CGI script.

################################################################################

ERROR CODES:

Error codes were added for better debugging within the script.
Each error code is related to a specific script only.

LIST:

ERROR CODE / SCRIPT

1 / master.sh (Master script)
2 / ccheck.sh (Server status check script)
3 / drotation.sh (Dynamic Rotation script)
4 / html.sh (HTML server status generator script)

################################################################################

CHANGELOG:

Changes from V1 to V2:

Added a single configuration file, you no longer have to check all the scripts.
Added a USER variable for more precise process checks.
Added comments in all areas for easy understanding.
MBIIServer.bat is no longer a static BATCH file, it's now created by the script each time you run it. All configurations in scripts.cfg will be passed to the batch file aswell.
Added the option of changing the nmap UDP check method from normal to spoofed in the scripts.cfg.

Changes from V2 to V3.00:

Support for all versions added.
Most lines have been either cleaned or optimized, error check for wrong values also has been added.
Dynamic Rotation added.
Updater added.

Changes from V3.00 to V3.01:

The code has been further cleaned and optimized.
All error checks with the exception of autodownload and server.cfg, have been migrated to the master script.
All error checks have been improved.
Added some echo messages for better interpretation in the stdout.

Changes from V3.01 to V3.02:

Check for directory and user errors added to the master script.
CFG files are now stored at the cfg folder, while previous version files after auto update are stored in the old folder.
Code for the updater has been further improved.

Changes from V3.02 to V3.03:

Moved the variable for process status check (running or not running) to the correct place to avoid misinformation within the script.

Changes from V3.03 to V4.00:

Log server feature added.
Log server start/restart feature added.
Auto-generated batch script Starter.bat was removed, a recursive bash script was added in its place.
Ncat check method added.
Dynamic Rotation monthly type added.
Dynamic Rotation map limit per rotation is now unlimited.
Added Dynamic Rotation rehash feature.
Dynamic Rotation is no longer stored with the server CFG. Instead a exec line is added, and the rotation is stored with an auto-generated file.
HTML server status page generator added.
CGI Script added.
Pid files have been added. script.pid for the script, and serverstarter.pid for the recursive script running the server.
Filesdir variable was removed. A new variable (scriptdir) has been added to check for the script directory automatically.
Error checks have been greatly improved and spread out through the entire code.
Error and exit codes have been added.
The entire code was re-checked, re-written, further improved and optimized for performance.
Updater has been further improved.

################################################################################

FAQ:

Q: Will you be releasing another version(s)?
A: Probably not. I have pushed this script far enough, and i don't have the same interest that i had before.

Q: I want to report a bug/feedback, or i need help, how can i contact you?
A: Via forum http://forums.moviebattles.com/showthread.php?t=32016 or via email yog.sothoth99@gmail.com.

Q: Which language did you use to code this script?
A: Scripts were coded in bash scripting, CGI script was coded in bash+html.

Q: Why this version does not contain separate restart time for each feature?
A: Main reason is to avoid overflow, but it's also to avoid executing several functions at the same time and breaking each other.

Q: Can i edit your script?
A: For personnal use, yes, for distribution, no. By distributing a version not made by me, a version hell will probably exist,
and the updater will be useless. If you have suggestions, contact me.

Q: Can i use your script on my mod?
A: Yes, as long as nothing is changed.

Q: Are you accepting donations?
A: Of course not. If you want to donate, donate to those who made this script possible at http://www.nmap.org.

################################################################################

Thanks to: (People who helped me at some point)

eXploit
=Someone=
Necrom
Kaynehril
TK-231
AceVentura
Lervish
*NSOQ*Lagawan 1.0
*NSOQ*Wolfman
*NSOQ*Helter Skelter
[CR]QuetzalCoalt
[CR]Tipo

-------------------------------------------------------------

* Cthulhu@GBITnet.com.br / 2010 ©